package com.tintuc24h.untils;

import java.net.URL;
import java.util.List;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;

import com.tintuc24h.models.RssItem;

public class Rssparse {

	public List<RssItem> getNewList(String link) {
		try {
			URL url = new URL(link);
			SAXParserFactory factory = SAXParserFactory.newInstance();
			SAXParser parser = factory.newSAXParser();
			XMLReader reader = parser.getXMLReader();
			RssHandles handles = new RssHandles();
			reader.setContentHandler(handles);
			InputSource source = new InputSource(url.openStream());
			reader.parse(source);
			return handles.getItemlist();

		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
}
